package tests;

import common.Utils;
import org.openqa.selenium.By;

public class ListPage  extends Utils {
    public static String url = "http://124.223.114.169:8080/blog_list.html";//list页面的URL

    public ListPage() {
        super(url);
    }


    /**
     * 成功登录之后看到的界面
     * 技巧：
     *     其实这个可能和login页面成功登录之后跳转页的逻辑判断差不多
     */
    public void ListByLogin() {
        //查看是否存在标志性元素
        driver.findElement(By.cssSelector("body > div.container > div.left > div > h3"));

        //查看页面的标题/URL是否符合预期跳转
        String expect = driver.getTitle();
        assert expect.equals("博客列表");

        //查看功能
        //1.查看详情  点击，跳转
        driver.findElement(By.cssSelector("body > div.container > div.right > div:nth-child(1) > a")).click();
        String detailtitle = driver.getTitle();
        assert detailtitle.equals("博客详情页 ");

        //2.编写博客 点击，跳转
        driver.navigate().back();
        driver.findElement(By.cssSelector("body > div.nav > a:nth-child(5)")).click();
        String writetitle = driver.getTitle();
        assert writetitle.equals("博客编辑页 ");

        //3.注销  点击，跳转
        driver.navigate().back();
        driver.findElement(By.cssSelector("body > div.nav > a:nth-child(6)")).click();
        String logintitle = driver.getTitle();
        assert logintitle.equals("博客登录页 ");

    }
}
